<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ include file="../common/htmlHeader.jsp"%>
<title>Insert title here</title>
</head>
<body>
	<div class="form-group" id="fileuploader">
		<input type="file" id="file" name="file"> 
	</div>
	<div class="page-header">
		<h1 class="text-center">欢迎新增用户页面<small>loginId: ${user.userId}</small></h1>
	</div>
	<div class="container-fluid">
		<form action="addUser" method="post">
			<input type="image" id="headImg" style="width: 140px;" hidden>
			<input type="text" name="headImg" hidden>
			<div class="form-group">
			  <label for="account">账号</label>
			  <input type="text" class="form-control" name="account" id="account" placeholder="account">
			</div>
			<div class="form-group">
			  <label for="name">真实姓名</label>
			  <input type="text" class="form-control" name="name" id="name" placeholder="name">
			</div>
			<div class="form-group">
			  <label for="nickname">昵称</label>
			  <input type="text" class="form-control" name="nickname" id="nickname" placeholder="nickname">
			</div>
			<div class="form-group">
			  <label for="password">Password</label>
			  <input type="password" class="form-control" name="password" id="password" placeholder="Password">
			</div>
			<input type="text" id="nowRegion" name="nowRegion" hidden>
			<input type="text" id="nowRegionId" name="nowRegionId" hidden>
			<input type="text" id="nowRegionLL" name="nowRegionLL" hidden>
			<div class="checkbox">
			  <label>
			    <input type="checkbox"> Check me out
			  </label>
			</div>
			<button type="submit" class="btn btn-default">Submit</button>
		</form>
	</div>
	<%@ include file="../common/htmlFooter.jsp"%>
	<script>
	$(document).ready(function()
	{	
		$.get(
			"http://webapi.amap.com/maps/ipLocation?key=489948cc5e88206aa4d323b690c0f6eb",
			function(data,status){
				$("#nowRegion").val(data.city);
				$("#nowRegionId").val(data.adcode);
				$("#nowRegionLL").val(data.center);
	    	},
	    	"jsonp"
	    );
		
		$("#fileuploader").uploadFile({
		url:"uploadHeadImg",
		fileName:"file",
		returnType:"json",
		onSuccess:function(files,data,xhr,pd,fileUrl)
		{	
			$("#headImg").removeAttr("hidden"); 
			$("#headImg").attr("src",data.fileUrl);
			$("#headImg").next().val(data.fileUrl);
		    //files: list of files
		    //data: response from server
		    //xhr : jquer xhr object
		},
		});
	});
	</script>
</body>
</html>